package bsc.war.mail;

import bsc.ejb.entity.Person;
import bsc.ejb.entity.ScoreCard;
import bsc.ejb.metadata.SMTP;
import javax.servlet.ServletContext;

/**
 *
 * @author Memo
 */
public class MailUtils {
    public enum Type{POINTER_DASHBOARD,SCORECARD_DASHBOARD,PROJECT_DASHBOARD,NOTIFICATION,PASSWORD_RECOVERY};
    
    public static final String scoreCardAlert = "jsp/mail/scoreCardAlert.jsp";
    public static final String pointerAlert = "jsp/mail/pointerAlert.jsp";
    public static final String projectAlert = "jsp/mail/projectAlert.jsp";
    //public static final String notification = "jsp/mail/projectAlert.jsp";
    //public static final String passwordRecovery = "jsp/mail/projectAlert.jsp";
    
    public static boolean sendMail(Person person, ScoreCard scoreCard, Type type, SMTP smtp, ServletContext context){
        Relay smtp_relay = new Relay(person, scoreCard, type);
        smtp_relay.send(smtp, context);
        return !smtp_relay.getError();
    }
    
    public static boolean isEmail(String email){
        return email.matches("^([A-Za-z0-9_\\-\\.])+\\@([A-Za-z0-9_\\-\\.])+\\.([A-Za-z]{2,4})$");
    }

    public static final String REPLY_MAIL = "noreply@enable.com";
    public static final String PORT = "465";
    public static final boolean AUTH = true;
}
